﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using wpf.prism.Models;
using wpf.prism.Serivces;

namespace wpf.prism.ViewModels
{
    public class DashboardViewModel : BindableBase
    {
        private readonly IRegionManager regionManager;

        public DashboardViewModel(INavigationMenuService navigationMenuService, IRegionManager regionManager)
        {
            NavigationService = navigationMenuService;
            this.regionManager = regionManager;
        }
        public INavigationMenuService NavigationService { get; }


        public DelegateCommand<NavigationItem> OpenViewCommand => new DelegateCommand<NavigationItem>(OpenView);

        private void OpenView(NavigationItem item)
        {
            regionManager.Regions["MainViewRegion"].RequestNavigate(item.PageName);
        }
    }
}
